
*** Figure 2b and Figure 2c
	

* Figure 2b (imports)
				import excel "Data/BilateralTradeGermany.xlsx", sheet("Sheet1") firstrow clear

				encode Tradingpartner, gen(Tradingpartner_enc)

				xtset Tradingpartner_enc Year 


				 gen aggregate_trade=Imports+Exports
				 gen MX=aggregate_trade
				egen MX_conti=sum(aggregate_trade)  if Tradingpartner!="All" & Tradingpartner!="US" & Tradingpartner!="UK", by(Year )
				egen X_conti=sum(Exports)  if Tradingpartner!="All" & Tradingpartner!="US" & Tradingpartner!="UK", by(Year )


				foreach x in Imports Exports MX MX_conti X_conti {
				gen tot_`x'_i=`x' if  Tradingpartner=="All"
				egen tot_`x'=mean(tot_`x'_i), by(Year)
				drop tot_`x'_i
				gen s_`x'=`x'/tot_`x'
				 gen Index_`x'_base=`x' if Year==1933
				 egen Index_`x'_base_all=mean(Index_`x'_base), by(Tradingpartner)
				 gen Index_`x'=100* `x'/Index_`x'_base_all  

				 drop *_base *_base_all
				}


				drop if Year==1937
				 



				 gen index_plot= Index_X_conti 	  
				 
				 replace index_plot=Index_Exports  if  Tradingpartner=="All"  
				 replace index_plot=Index_Exports  if  Tradingpartner=="UK" 
				 replace index_plot=Index_Exports  if  Tradingpartner=="US" 
				 
				  

				 gen barorder=1 if  Tradingpartner=="All"  
				 replace barorder=2 if  Tradingpartner=="UK"  
				 replace barorder=4 if  Tradingpartner=="US"  
				 replace barorder=3 if  Tradingpartner=="NLD"  
				 
				 label define Tradingpartner_enc_label 1 "All tradingpartners" 4 "Continental creditors" 5 "UK" 6 "US"
				 label values Tradingpartner_enc  Tradingpartner_enc_label

				 
				 
				 
				graph bar index_plot if Year==1936 & Tradingpartner!="CH" & Tradingpartner!="FR", over(Tradingpartner_enc, ///
				sort (barorder) ) ytitle("Exports in 1936 (1933=100)") label xsize(3) ysize(4)


				graph export "Output/Figure2b.pdf", replace 


  

* Figure 2c (imports + exports)	

				replace index_plot=Index_MX_conti
				replace index_plot=Index_MX  if  Tradingpartner=="All"  
				replace index_plot=Index_MX  if  Tradingpartner=="UK" 
				replace index_plot=Index_MX  if  Tradingpartner=="US" 
			 
			   
			 

				graph bar index_plot if Year==1936 & Tradingpartner!="CH" & Tradingpartner!="FR", over(Tradingpartner_enc, ///
				sort (barorder) ) ytitle("Aggregate trade in 1936 (1933=100)") label xsize(3) ysize(4) 


				graph export "Output/Figure2c.pdf", replace 




* Figure 3




*Figure 3a

				import excel "Data/BilateralTradeGermany.xlsx", sheet("Sheet1") firstrow clear

				encode Tradingpartner, gen(Tradingpartner_enc)

				xtset Tradingpartner_enc Year 

				keep if Year==1933

				gen net_exports=Exports-Imports

				graph bar net_exports if  Tradingpartner!="UK_incl_EMPIRE" & Tradingpartner!="NLD_incl_EMPIRE" & Tradingpartner!="FR_incl_EMPIRE" & Tradingpartner!="All", ///
				over(Tradingpartner_enc, sort (net_exports) )  ytitle("German trade balance in 1933 vis-à-vis creditor" "(in m Reichsmark)") label xsize(3) ysize(4) 

				graph export "Output/Figure3a.pdf", replace 




*** Plot overall importance 

				import excel "Data/BilateralTradeGermany.xlsx", sheet("Sheet1") firstrow clear

				encode Tradingpartner, gen(Tradingpartner_enc)

				xtset Tradingpartner_enc Year 

				keep if Year==1933

					gen aggregate_trade=Imports+Exports
				  
						  foreach x in Exports Imports{
							replace `x'_inclCol=`x' if `x'_inclCol==. 
						  }
						 
					gen Exports_colonies= Exports_inclCol-Exports
					gen Imports_colonies= Imports_inclCol-Imports
					
					gen aggregate_trade_colonies=Exports_colonies+Imports_colonies
				  
					sort Tradingpartner
				  
					gen aggregate_trade_all= aggregate_trade[1]
				  
					gen share_overall_trade=100*aggregate_trade/aggregate_trade_all
					gen share_overall_trade_colonies=100*aggregate_trade_colonies/aggregate_trade_all

					gen share_inclCOl=share_overall_trade+share_overall_trade_colonies
				 
				 
					graph bar share_overall_trade  share_overall_trade_colonies if    Tradingpartner!="All", over(Tradingpartner_enc, sort (share_inclCOl) ) ///
					ytitle("Shares in aggregate trade with creditors" "in %") ylabel(0(5)20) label xsize(3) ysize(4) stack legend(pos(6) order(1 "Country"  2  "Empire") col(2))

					graph export "Output/Figure3b.pdf", replace 

	 
 ** Plot overall importance (imports)

				import excel "Data/BilateralTradeGermany.xlsx", sheet("Sheet1") firstrow clear

				encode Tradingpartner, gen(Tradingpartner_enc)

				xtset Tradingpartner_enc Year 

				keep if Year==1933

				   
				  foreach x in Exports Imports{
					replace `x'_inclCol=`x' if `x'_inclCol==. 
				  }
				 
				   gen Exports_colonies= Exports_inclCol-Exports
				   gen Imports_colonies= Imports_inclCol-Imports
					
					gen aggregate_trade_colonies=Exports_colonies+Imports_colonies
				  
				  sort Tradingpartner
				  
				  gen aggregate_imports_all= Imports[1]
				  
				  gen share_overall_imports=100*Imports/aggregate_imports_all
				  gen share_overall_imports_colonies=100*Imports_colonies/aggregate_imports_all

				  gen share_inclCOl=share_overall_imports+share_overall_imports_colonies
				 
				 
				 graph bar share_overall_imports  share_overall_imports_colonies  if    Tradingpartner!="All", over(Tradingpartner_enc, sort (share_inclCOl) ) ///
				 ytitle("Shares in total imports of creditor" "in %") label xsize(3) ysize(4) stack legend(pos(6) order(1 "Country"  2  "Empire") col(2))

				 graph export "Output/Figure3c.pdf", replace 



 
* Figure 5a


 
 **** Plot exports to creditor over time
 
 
 	import excel "Data/BilateralTradeGermany.xlsx", sheet("Sheet1") firstrow clear

	keep Exports Tradingpartner Year
	
	drop if Tradingpartner=="All"
	
	drop if Year<1933
	
	reshape wide Exports, i(Year) j(Tradingpartner ) string
	

	
	foreach x in ExportsCH ExportsFR ExportsNLD ExportsUK ExportsUS{
		gen `x'_1933=100*(`x'/`x'[1])
	}
	
	
	label var ExportsCH_1933 Switzerland
	label var ExportsFR_1933 France 
	label var ExportsNLD_1933 Netherlands
	label var ExportsUK_1933 "United Kingdom"
	label var ExportsUS_1933 "United States" 
	
	
						
	twoway (connected ExportsUK_1933 ExportsFR_1933   ExportsNLD_1933 ExportsCH_1933  ExportsUS_1933 Year, xsize(5.3) ylabel(,labsize(small)) ///
	lcolor( blue red dkorange green maroon)  mcolor( blue red dkorange green maroon) 	bgcolor(white)  graphregion(color(white))  bgcolor(white) ///
	bgcolor(white) ytitle("{stMono:Imports from Germany (1933=100)}", size(small)) xtitle("") legend(c(5)  size(small) pos(6) ring(2) region(lcolor(none) ))) 
						
	 graph export "Output/Figure5a.pdf", replace 
					
 
 

